#ifndef CPATH_H_INCLUDED
#define CPATH_H_INCLUDED

#include <libtcod/libtcod.hpp>

#include "Utils.h"

class CPath
{
public:
	~CPath()
	{
		delete Path;
	}

	bool isPathOver()
	{
		return Path->isEmpty();
	}

	pair getDestination()
	{
	    int x = 0, y = 0;
	    Path->getDestination(&x, &y);
	    return pair(x, y);
	}

	void change(pair newPosition, pair newDestination)
	{
		Path->compute(newPosition.x(), newPosition.y(), newDestination.x(), newDestination.y());
	}

	void create(TCODMap* map, pair position, pair destination)
	{
		Path = new TCODPath(map, 1.0f);
		Path->compute(position.x(), position.y(), destination.x(), destination.y());
	}

	void move(int* x, int* y)
	{
		if (!Path->isEmpty())
			Path->walk(x, y, true);
	}

private:
	TCODPath* Path;
};

#endif
